package sapling.dao;

import sapling.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by ever on 2016/10/9.
 */

@Transactional
public interface UserDao extends JpaRepository<User, Long> {

    List<User> findByUsername(String username);

    User findOneByUsername(String username);

    List<User> findByUsernameAndPassword(String username, String password);


    @Modifying
    @Query("update User u set u.password = ?1 where u.username = ?2")
    int setFixedPasswordFor(String password, String username);

    User findByTooken(String tooken);
}
